package org.ourgrid.broker.scheduler.workqueue.xmlcreator;

import org.ourgrid.common.FileTransferInfo;

public class GetFilesXMLCreator implements XMLCreatorIF {
	
	
	/**
	 * <GET_FILES workerID='String' requestID='long'>
	 *    1..n <FILE transferHandleID='long' filePath='String'/> 
	 * </GET_FILES> 
	 */
	public String getXML(String workerID, long requestID, FileTransferInfo[] files) {
		
		StringBuffer buffer = new StringBuffer();
		
		buffer.append("<GET_FILES ");
		buffer.append("workerID='" + workerID + "' ");
		buffer.append("requestID='" + requestID + "'> ");
		buffer.append(SEP);
		
		if (files != null) {
			for (FileTransferInfo file : files) {
				buffer.append("<FILE transferHandleID='" + file.getTransferHandleID() + 
						"' filePath='" + file.getFilePath() + "'/>" + SEP);
			}
		}
		
		buffer.append("</GET_FILES>");
		
		return buffer.toString();
	}
	
	

}
